package cn.itsource.aigou.controller;

import cn.itsource.aigou.domain.User;
import cn.itsource.aigou.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

@RestController
public class LoginController {

    //swagger可以通过注解描述这个接口信息
    //@RequestMapping(value = "/login",method = RequestMethod.POST)
    @PostMapping("/login")
    public AjaxResult login(@RequestBody User user){
        //模拟一个登录  admin  admin
        String username = user.getUsername();
        String password = user.getPassword();

        if("admin".equals(username)&&"admin".equals(password)){
            user.setPassword(null);
            return AjaxResult.me().setSuccess(true).setMessage("登录成功!").setRestObj(user);
        }

        return AjaxResult.me().setSuccess(false).setMessage("登录失败!");
    }

}
